<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;

// 认证相关路由
Route::group('auth', function () {
    Route::post('login', 'Auth/login')->middleware(\app\middleware\OperateLog::class);
    Route::post('logout', 'Auth/logout')->middleware(\app\middleware\OperateLog::class);
    Route::get('info', 'Auth/getUserInfo')->middleware(\app\middleware\JwtAuth::class);
});

// 需要认证的路由组
Route::group('api', function () {
    // 用户管理
    Route::group('user', function () {
        Route::get('list', 'User/index');
        Route::post('add', 'User/add')->middleware(\app\middleware\OperateLog::class);
        Route::put('edit', 'User/edit')->middleware(\app\middleware\OperateLog::class);
        Route::delete('delete/:id', 'User/delete')->middleware(\app\middleware\OperateLog::class);
        Route::get('detail', 'User/detail');
    });
    
    // 设备管理
    Route::group('device', function () {
        Route::get('list', 'Device/index');
        Route::post('add', 'Device/add')->middleware(\app\middleware\OperateLog::class);
        Route::put('edit', 'Device/edit')->middleware(\app\middleware\OperateLog::class);
        Route::delete('delete/:id', 'Device/delete')->middleware(\app\middleware\OperateLog::class);
        Route::get('data/:id', 'Device/getData');
    });
    
    // 设备组管理
    Route::group('device_group', function () {
        Route::get('list', 'DeviceGroup/index');
        Route::post('add', 'DeviceGroup/add');
        Route::put('edit', 'DeviceGroup/edit');
        Route::get('detail', 'DeviceGroup/detail');
        Route::delete('delete/:id', 'DeviceGroup/delete');
    });
    
    // 系统管理路由组
    Route::group('system', function () {
        Route::get('role/list', 'Role/index');
        Route::post('role/add', 'Role/add')->middleware(\app\middleware\OperateLog::class);
        Route::put('role/edit', 'Role/edit')->middleware(\app\middleware\OperateLog::class);
        Route::delete('role/delete/:id', 'Role/delete')->middleware(\app\middleware\OperateLog::class);
        Route::get('role/all', 'Role/all');
        Route::get('role/permissionIds', 'Role/permissionIds');

        Route::get('permission/list', 'Permission/index');
        Route::post('permission/add', 'Permission/add')->middleware(\app\middleware\OperateLog::class);
        Route::put('permission/edit', 'Permission/edit')->middleware(\app\middleware\OperateLog::class);
        Route::delete('permission/delete/:id', 'Permission/delete')->middleware(\app\middleware\OperateLog::class);
        Route::get('permission/detail', 'Permission/detail');

        // 新增配置管理路由
        Route::group('config', function () {
            Route::get('list', 'Config/index')->middleware(\app\middleware\OperateLog::class);
            Route::post('add', 'Config/add')->middleware(\app\middleware\OperateLog::class);
            Route::put('edit', 'Config/edit')->middleware(\app\middleware\OperateLog::class);
            Route::delete('delete/:id', 'Config/delete')->middleware(\app\middleware\OperateLog::class);
            Route::get('detail/:id', 'Config/detail');
        });
        
        Route::get('monitor/statistics', 'Monitor/statistics');

        Route::get('log/list', 'Log/operationList');
        Route::get('log/statistics', 'Log/operationStats');
    });
    
})->middleware(\app\middleware\JwtAuth::class); 